<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算属性的setter getter</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
    <div id="app">
        <h2>{{ fullName }}</h2>
    </div>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                firstName: "Kobe",
                lastName: "Bryant"
            },
            computed: {

                //一般写法
                // fullName: function(){
                //     return this.firstName + '' + this.lastName
                // }


                //完整写法
                fullName: {
                    set: function() {//一般情况下，没有set方法,是一个只读属性
                        console.log("252")
                    },
                    get: function() {
                        return this.firstName + '' + this.lastName
                    }
                }

            }
        })
    </script>
</body>
</html>